﻿<%@ Page Language="C#" MasterPageFile="~/Templates/Member.master" AutoEventWireup="true"
    CodeFile="Member-Collection.aspx.cs" Inherits="member_Collection" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager runat="server" ID="ScriptManager1" EnablePageMethods="true" EnablePartialRendering="true">
    </asp:ScriptManager>
    <div class="toptitle">
        我的收藏</div>
    <div id="mbc-my-fav" class="Collection">
        <div class="ItemsWarp clearfix" style="width: 100%;">
            <div class="items-list">
                <div id="goodsbody">
                    <table id="tblFavs" class="goods-spec memberlist" width="100%" cellspacing="0" cellpadding="1">
                        <tr class="tableHeader" style="line-height: 30px;">
                            <%--<td>
                                <input id="SelectAll" type="checkbox" value="" onclick="SelectAllProduct(this)" /><label
                                    for="SelectAll">
                                    全选</label>
                            </td>--%>
                            <td colspan="2">
                                商品信息</td>
                            <td>
                                销售价格</td>
                            <td colspan="2">
                                操作</td>
                        </tr>
                        <tr>
                            <td colspan="5">
                                <br />
                            </td>
                        </tr>
                        <asp:UpdatePanel runat="server" ID="upFav" ChildrenAsTriggers="false" UpdateMode="Conditional">
                            <ContentTemplate>
                                <%= strConent%>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </table>
                </div>
                <asp:TextBox ID="txtProID" runat="server" Style="display: none;"></asp:TextBox>
                <asp:TextBox ID="txtColor" runat="server" Style="display: none;"></asp:TextBox>
                <asp:TextBox ID="txtSize" runat="server" Style="display: none;"></asp:TextBox>
                <asp:TextBox ID="txtCount" runat="server" Style="display: none;"></asp:TextBox>
                <asp:Button ID="btnAddFav" runat="server" Text="增加到购物车" Style="display: none;" OnClick="btnAddFav_Click" />
            </div>
            <div class="CartBtn clearfix" style="margin-bottom: 5px; width: 100%;">
                <div class="span-auto" style="float: right;">
                    <a id="clearCollecion" class="actbtn btn-clearcat" style="background-image: url(img/themes/btn-clearcollection.png);
                        width: 126px;" href="javascript:DeleteAllCollection(this);">删除所有收藏的商品</a>
                </div>
            </div>
        </div>
    </div>

    <script language="javascript" type="text/javascript">
        function SelectAllProduct(obj)
        {
                var tbl = document.getElementById("tblFavs");
                var rows = tbl.rows
                if(rows.length>1)
                {
                    for(var i=1;i<rows.length;i++)
                    {
                        var chk = rows[i].cells[0].getElementsByTagName("input")[0];
                        chk.checked = obj.checked;
                    }
                }
         }

        function DeleteRow(favID)
        {
            var tbl = document.getElementById("tblFavs");
            var rows = tbl.rows
            if(rows.length>1)
            {
                for(var i=1;i<rows.length;i++)
                {
                    var rw = rows[i];
                    if(rw.getAttribute("favID")==favID)
                    {
                        tbl.deleteRow(i);
                        return;
                    }
                }
            }
        }
        
        function DeleteAllRow()
        {
            var tbl = document.getElementById("tblFavs");
            var rows = tbl.rows
            if(rows.length>1)
            { 
                for(var i=rows.length;i>1;i--)
                { 
                    tbl.deleteRow(i-1);
                }
            }
        }
        
        function DeleteAllCollection(obj)
        {
            obj.disabled = true;
            $.ajax(
            {
              type: "POST",
              url: "ashx/CollectionDeleteAll.ashx" , 
              dataType: "json",
              success: function(data) {
                if(data.success)
                {
                    DeleteAllRow();
                }
                   
              },
              error:function(){
                alert("删除失败！");
              }
            }
        );
    }
        
        function DeleteCollection(favID,obj)
        { 
            obj.disabled = true;
            $.ajax(
            {
              type: "POST",
              url: "ashx/CollectionDelete.ashx" ,
              data: "favID="+favID,
              dataType: "json",
              success: function(data) {
                if(data.success)
                {
                    DeleteRow(data.msg);
                }
                   
              },
              error:function(){
                alert("删除失败！");
              }
            }
        );               
    }
    
    function DoAdd()
    {
        document.getElementById("<%= this.btnAddFav.ClientID %>").click();
    }
   
    $(document).ready(function(){
         $(".ulColor li a").click(function(){
            $(".ulColor li a").removeClass('selected');
            $(this).addClass('selected');
      });
    $(".ulColor li").click(function(){
         var index=$('.ulColor li').index(this);
         var colorID = $(".ulColor li:eq("+index+")").attr("value");
                                    
         $("#ctl00_ContentPlaceHolder1_txtColor").attr("value",'');
         $("#ctl00_ContentPlaceHolder1_txtColor").attr("value",colorID);
       });
       
       
                                                            
       $(".ulSize li a").click(function(){
         $(".ulSize li a").removeClass('selected');
         $(this).addClass('selected');
       });
       $(".ulSize li").click(function(){
         var index=$('.ulSize li').index(this);
         var sizeID = $(".ulSize li:eq("+index+")").attr("value");
         $("#ctl00_ContentPlaceHolder1_txtSize").attr("value",'');
         $("#ctl00_ContentPlaceHolder1_txtSize").attr("value",sizeID);
       });
       $(".Numinput .increase").click(function(){
         var count=$("#txtCount").attr("value");
         $("#ctl00_ContentPlaceHolder1_txtCount").attr("value",'');
         $("#ctl00_ContentPlaceHolder1_txtCount").attr("value",count);
       });
       $(".Numinput .decrease").click(function(){
         var count=$("#txtCount").attr("value");
         $("#ctl00_ContentPlaceHolder1_txtCount").attr("value",'');
         $("#ctl00_ContentPlaceHolder1_txtCount").attr("value",count);
       });
        var count=$("#txtCount").attr("value");
        $("#ctl00_ContentPlaceHolder1_txtCount").attr("value",'');
        $("#ctl00_ContentPlaceHolder1_txtCount").attr("value",count);
      });
                                                      
     function checkTextboxValue(obj,min,max,defaultValue)
     {
	    var val=parseInt(obj.value);
	    if(isNaN(val) || val>max || val<min) {
            obj.value=defaultValue;
	    } else {
		    obj.value=val;
	    }
      }
     function ItemNumAdd(obj,count)
     {
         var objParent = obj.parentNode;
         var objText = objParent.getElementsByTagName("input")[0];
     
         var val = parseInt(objText.value) + count;
         objText.value = val;
         checkTextboxValue(objText,1,999,1);
      }
     
                                                        
     $$('.buy-select-list').setStyle('display','none').hide();
     $$('.Collection .buy-select').addEvent('mouseover',function(){
          var index=$('.Collection .buy-select').index(this);
          var proID = $(".Collection .buy-select:eq("+index+")").attr("value");
          
          $$('#buy-select-list'+proID).setStyle('display','block').show();
          
          $("#ctl00_ContentPlaceHolder1_txtProID").attr("value",'');
          $("#ctl00_ContentPlaceHolder1_txtProID").attr("value",proID);
      });
     $$('.Collection .buy-select').addEvent('mouseout',function(){
          var index=$('.Collection .buy-select').index(this);
          var proID = $(".Collection .buy-select:eq("+index+")").attr("value");
          $$('#buy-select-list'+proID).setStyle('display','none').hide();
     });
    </script>
    <script type="text/javascript">
         /*$('.ulColor li a').click(function(){
         $.ajax({
            url:'Member-Collection.aspx',
            data:null,
            type:'post',
            success:function(result){
                $('.ulColor').html(result);
            }
         })
       });*/
    </script>
    <script type="text/javascript">
        /*$('.ulSize li a').click(function(){
         $.ajax({
            url:'Member-Collection.aspx',
            data:null,
            type:'post',
            success:function(result){
                $('.ulSize').html(result);
            }
         })
       });*/
    </script>

    <asp:UpdatePanel ID="UpdatePanelAlert" runat="server" ChildrenAsTriggers="False"
        UpdateMode="Conditional" Visible="False">
    </asp:UpdatePanel>
</asp:Content>
